package com.doit.day03;

import com.alibaba.fastjson.JSON;
import com.doit.day02.EventLog;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Map;

public class MyInterceptor implements org.apache.kafka.clients.producer.ProducerInterceptor{
    @Override
    public ProducerRecord onSend(ProducerRecord record) {
        String s = record.value().toString();
        EventLog eventLog = JSON.parseObject(s, EventLog.class);
        if (eventLog.getGuid() %2 == 0){
            return record;
        }else {
            return null;
        }
    }

    @Override
    public void onAcknowledgement(RecordMetadata metadata, Exception exception) {

    }

    @Override
    public void close() {

    }

    @Override
    public void configure(Map<String, ?> configs) {

    }
}
